# -*- coding: utf-8 -*-

from datetime import datetime
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError


class do_something(models.TransientModel):
    _name = 'do.someting'


    def stock_reserve(self):
        context = dict(self._context or {})
        stock_move_ids= (context.get('active_ids'))
        for i in stock_move_ids:
            stock_move_object = self.env['stock.move'].search([('id','=',i)])
            if stock_move_object.state not in ('draft', 'cancel', 'done'):
                stock_move_object.action_assign()


    def do_un_stock_reserve(self):
        context = dict(self._context or {})
        stock_move_ids= (context.get('active_ids'))
        for i in stock_move_ids:
            stock_move_object = self.env['stock.move'].search([('id','=',i)])
            stock_move_object.do_unreserve()


    def do_cancel(self):
        context = dict(self._context or {})
        stock_move_ids= (context.get('active_ids'))
        for i in stock_move_ids:
            stock_move_object = self.env['stock.move'].search([('id','=',i)])
            stock_move_object.do_unreserve()
            stock_move_object.action_cancel()


